import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 涛
 * Date: 2023-09-29
 * Time: 10:25
 */
class Solution {
    public int removeElement(int[] nums, int val) {
        int[] newArryList =nums;
        int size = nums.length;
        //如果一个元素都没有
        if(size == 0) {
            return -1;
        }
        //便利一遍数组，找到数组含val的下标
        for(int i = 0; i < size; i++) {
            if(nums[i] == val) {
                //下标的值等于val,删除
                newArryList = removeArryList(i, newArryList);
            }
        }
        return newArryList.length;
    }
    public int[] removeArryList(int mark, int[] nums) {
        int[] removeArryList = nums;
        int len = removeArryList.length;
        int i = mark;
        for(; i < len - 1; i++) {
            removeArryList[i] = removeArryList[i + 1];
        }
        removeArryList[i] = '\0';
        return removeArryList;
    }
}
public class Test1 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] num = {3,2,2,3};
        int val = 3;
        //for (int x:num) {
        //    System.out.println(x);
        //}
        int mark = solution.removeElement(num, val);
        System.out.println("================");
        for (int i = 0; i < mark; i++) {
            System.out.println(num[i] + " ");
        }

    }
}
